<!DOCTYPE html>
<html lang="${LANG}">

<head>
    <meta charset="UTF-8">
    <title>QBT_TR(Add trackers)QBT_TR[CONTEXT=TrackersAdditionDialog]</title>
    <link rel="stylesheet" href="css/style.css?v=${CACHEID}" type="text/css">
    <script src="scripts/lib/MooTools-Core-1.6.0-compat-compressed.js"></script>
    <script src="scripts/lib/MooTools-More-1.6.0-compat-compressed.js"></script>
    <script>
        "use strict";

        window.addEventListener("DOMContentLoaded", () => {
            new Keyboard({
                defaultEventType: "keydown",
                events: {
                    "Escape": function(event) {
                        window.parent.qBittorrent.Client.closeWindows();
                        event.preventDefault();
                    },
                    "Esc": function(event) {
                        window.parent.qBittorrent.Client.closeWindows();
                        event.preventDefault();
                    }
                }
            }).activate();

            $("trackersUrls").focus();
            $("addTrackersButton").addEventListener("click", (e) => {
                e.preventDefault();
                e.stopPropagation();

                const hash = new URI().getData("hash");
                new Request({
                    url: "api/v2/torrents/addTrackers",
                    method: "post",
                    data: {
                        hash: hash,
                        urls: $("trackersUrls").value
                    },
                    onComplete: function() {
                        window.parent.qBittorrent.Client.closeWindows();
                    }
                }).send();
            });
        });
    </script>
</head>

<body>
    <div style="text-align: center; margin-top: 10px;">
        <label for="trackersUrls">QBT_TR(List of trackers to add (one per line):)QBT_TR[CONTEXT=TrackersAdditionDialog]</label>
        <textarea name="list" id="trackersUrls" rows="10" cols="1"></textarea>
        <input type="button" value="QBT_TR(Add)QBT_TR[CONTEXT=HttpServer]" id="addTrackersButton">
    </div>
</body>

</html>
